

//////////////////////////

End="";

nul=[] execVM "Include\KRON_Strings.sqf";   
ServerInitEnds=false;
isDebug=true;
enableEnvironment false;

debug={
	if(isDebug)then{
		_message=_this;
		h1 globalChat _message;
	};
};

MatrixAddTask={
	_title=_this select 0;
	_desc=_this select 1;
	
	_tsk = player createSimpleTask [_title];
	_tsk setSimpleTaskDescription [(localize _desc), (localize _title), (localize _title)];
	
	if((count _this)>2)then{
		_tsk setSimpleTaskDestination (_this select 2);
	};
	
	_tsk settaskstate "Created";
	call compile format["%1=_tsk",_title];
	_tsk;
	
};

MatrixSetTaskState={
	_task=_this select 0;
	_state=_this select 1;

	
	_task settaskstate _state;
	[nil, nil, _task, _state] execvm "\ca\modules\mp\data\scriptcommands\taskhint.sqf";	
	_task settaskstate _state;
	
	if(_state=="Assigned")then{
		player setCurrentTask _task;
	};
};


GameEnd=false;


cabine=nil;
TankAddAmmo=nil;
TankAddWeapon=nil;

CabsList=[];


HumanObjectiveCompleted=false;

CivilDetectionDuration = Param1;
CivilDetectionRadius=Param2;

objNumbers=3;

Objective=objNull;
selectedCab=objNull;

isRinging=false;
isPhoneAnswered=false;

WeaponList=
[
	["AK47 M","AK_47_M","30Rnd_762x39_AK47",10],
	//["AK47 S","AK_47_S","30Rnd_762x39_AK47",10],
	["AK47 GL","AK_74_GL","30Rnd_762x39_AK47",10],
	["AKS74","AKS_74_U","30Rnd_545x39_AKSD",10],
	["AKS 74 UNKobra","30Rnd_545x39_AKSD",10],
	["RPK","RPK_74","75Rnd_545x39_RPK",10],
	["PK","PK","100Rnd_762x54_PK",10],
	["Hunting Rifle","huntingrifle","5x_22_LR_17_HMR",10],
	["SVD","SVD","10Rnd_762x54_SVD",10],
	["RPG7V","RPG7V","PG7V",10],
	//["Strela","Strela","Strela",10],
	["Makarov","Makarov","8Rnd_9x18_Makarov",10],
	["PipeBomb","Put","TimeBomb",1],
	["HandGrenade","Throw","HandGrenade",10],
	["Binocular","Binocular","Binocular",10],
	["NVGoggles","NVGoggles","NVGoggles",10]
];


/////////////////////////////////////////////////////////////////////////////////////////////////////


[] execVM "ServerWatchTankWeapons.sqf";


if (isServer)then{

    //cabine = "Land_KBud" createVehicle getPos cab_1;
   // player setPos getPos cab_1;
   [] execVM "testCab.sqf";
	ObjectiveNumber=ceil(random objNumbers);
	publicVariable "ObjectiveNumber";
	
	[] execVM "ServerWatchObjectives.sqf";
	
	[] execVM "ServerWatchEnd.sqf";
	
	[] execVM "ServerCreateBase.sqf";
	
	[] execVM "ServerCreateCivilian.sqf";
	//[configFile >> "CfgVehicles" >> "Civilian",true] call compile preprocessFileLineNumbers "dumpCfg.sqf";
	NearestBusStop={


		private["_location","_radius","_list","_obj"];
		_location = _this select 0;
		_radius = _this select 1;
		_obj=objNull;
		_list = nearestObjects [_location,[],_radius];
		
		
		
		{ // foreach objects
		
			//player globalChat ("TEST into "+str _x);
			
			if ( [str _x,"busstop"] call KRON_StrInStr ) then
			{
				//player globalChat ("busstop !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "+str _x+" => "+str time);
				_obj=_x;
				
			};

		}forEach _list;
			
			
		_obj
		
	};

};

// init local side
if (!isDedicated or !isServer)then{

	[] execVM "ClientWatchEnd.sqf";
    [] execVM "ClientWatchEvents.sqf";
    [] execVM "ServerRingThePhone.sqf";	
	
	
    switch (side player) do {

        // Agent
        case west : {
            [player] execVM "initAgent.sqf";
            //player globalChat format["ahaha 2 %1",HumanGroup];
         };

         // humans
        case resistance : {
			
            if(player != TankPlayer) then {
                 [player] execVM "initHuman.sqf";
            }else{
				"Im tank" call debug;
                 [player] execVM "initTank.sqf";
            };
			
			
			
        };
    };
};

waitUntil{	ServerInitEnds };

// create the obj marker for tank
/* _markerobj = createMarkerLocal["objMarker",getPos Objective];
_markerobj setMarkerShapeLocal "ICON";
_markerobj setMarkerTypeLocal "Destroy";
_markerobj setMarkerColorLocal "ColorRed";
_markerobj setMarkerTextLocal ""; */


